package cn.qdhlm.frontendprocessor.common;



import cn.qdhlm.frontendprocessor.common.config.MqttConfig;
import cn.qdhlm.frontendprocessor.common.config.SocketServer;
import cn.qdhlm.frontendprocessor.common.helper.MqttHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

import javax.management.Query;

/**
 * @Name:BootStrap
 * @description:
 * @author: xinY
 **/
@Component
public class Bootstrap implements ApplicationRunner {
    @Autowired
    private SocketServer socketServer;
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void run(ApplicationArguments args) {
        // 启动socket
        socketServer.start();
        // 订阅mqtt
        for (int i = 0 ; i < MqttConfig.topics.length ; i ++){
            MqttHelper.subscribe(MqttConfig.topics[i]);
        }
    }
}
